package com.shenmazong.serveredustudent.controller;

import com.shenmazong.serveredustudent.pojo.TbApply;
import com.shenmazong.serveredustudent.service.TbApplyService;
import com.shenmazong.utils.ResultResponse;
import com.shenmazong.vo.ListParamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author 满天星斗
 * @version 1.0
 * @description: TODO
 * @date 2021/9/26 14:44
 */

@RestController
@RequestMapping("/apply")
public class ApplyController {

    @Autowired
    private TbApplyService applyService;


    /**
     * @description commitApply
            * @params [apply]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/26 14:47
            */
    @PostMapping("/commitApply")
    public ResultResponse commitApply(@RequestBody TbApply apply){
        applyService.save(apply);
     return  ResultResponse.SUCCESS("申请提交成功");
    }

    /**
     * @description deleteApply
            * @params [apply]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/26 14:48
            */
    @PostMapping("/deleteApply")
    public ResultResponse deleteApply(@RequestBody TbApply apply){
        applyService.removeById(apply.getApplyId());
        return  ResultResponse.SUCCESS("申请删除成功");
    }

    /**
     * @description updateApply
            * @params [apply]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/26 14:49
            */
    @PostMapping("/updateApply")
    public ResultResponse updateApply(@RequestBody TbApply apply){
        applyService.updateById(apply);
        return  ResultResponse.SUCCESS("申请修改成功");
    }


    /**
     * @description 根据条件获取申请+分页
            * @params [apply]
            * @return com.shenmazong.utils.ResultResponse
            * @author S1763
            * @date 2021/9/26 14:51
            */
    @PostMapping("/getApplyPage")
    public ResultResponse getApplyPage(@RequestBody ListParamVo listParamVo){
        return  applyService.getApplyPage(listParamVo);
    }













}
